<?php

error_reporting(E_ALL);
require_once("CacheTag.class.php");

function f1()
{
	sleep(1);
	return 1;
}

function f2()
{
	sleep(1);
	return 2;
}

CacheTag::SetBackend(CacheTag::BACKEND_MEMCACHE);

//Adding var
CacheTag::SetFunction('f1');
CacheTag::SetTags(CacheTag::TAG_PRODUCT);
CacheTag::SetParam(CacheTag::PARAM_ID, 2);
CacheTag::SetTimeout(0.1);
CacheTag::Fetch();

//Adding another var (note the new param)
CacheTag::SetFunction('f2');
CacheTag::SetTags(CacheTag::TAG_PRODUCT);
CacheTag::SetParam(CacheTag::PARAM_ID, 2);
CacheTag::SetParam(CacheTag::PARAM_USER , 7);
CacheTag::SetTimeout(0.1);
CacheTag::Fetch();

//Deleting vars tagged with Product and with param id = 2
CacheTag::SetTags(CacheTag::TAG_PRODUCT);
CacheTag::SetParam(CacheTag::PARAM_ID, 2);
CacheTag::Flush();

/*
//This would delete all vars tagged with TAG_PRODUCT
CacheTag::SetTags(CacheTag::TAG_PRODUCT);
CacheTag::Flush();
*/